package com.zsy.springcloud.controller;

import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@Log4j2
@RestController
public class AccountConsumerController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping(value = "/getConsumerAccount", method = RequestMethod.GET)
    public Map<String,Object> getAccount() {
        Map<String,Object> account = new HashMap<>();
        log.info("---------消费者开始------------");
        //调用服务
        account = restTemplate.getForObject("http://cloud-account/getAccount", HashMap.class);
        log.info("---------消费者结束--------account{}----", account);
        return account;
    }
}
